<TITLE>Workflow.NET Memo with Workflow Fields</TITLE>
<STYLE><%#stylesheet%></STYLE>
<BODY marginheight="0" marginwidth="0" topmargin="0" leftmargin="0" width="300" onresize="resizecontrols();">
	<form name="wf_theform">
		<TABLE width="100%" height="100%" bgcolor="<%#bgcolor%>" cellspacing="0" cellpadding="0">
			<TR>
				<TD valign="top">
					<TABLE>
						<TR>
							<TD>
								<B>
									<%#actionname%>
									-</B><%#propertyname%>
							</TD>
							<TD align="right">
								<table ID="Table1">
									<tr>
										<td width="35">
											Field :
										</td>
										<td width="40">
											<SELECT id="Select3" name="Select3" language="javascript" onchange="return Select3_onclick();">
												<OPTION value="Variable">Variable</OPTION>
												<OPTION value="Content">Content</OPTION>
												<OPTION value="Value" selected>Value</OPTION>
												<OPTION value=""></OPTION>
											</SELECT>
										</td>
										<td>
											<div id="expr2">&nbsp;</div>
										</td>
										<td width="20">
											<input type="button" value="Append" onclick="return InsertField();" ID="Button2" NAME="Button2">
										</td>
									</tr>
								</table>
							</TD>
						</TR>
						<TR>
							<TD colspan="2">
								<Textarea style="width:<%#textareawidth%>;height:<%#textareaheight%>" class="list" id="wf_textarea" name="wf_textarea" ><%#value%></Textarea>
							</TD>
						</TR>
					</TABLE>
					<BR>
				</TD>
			</TR>
			<TR>
				<TD height="1" bgcolor="black"><IMG src="?drawimage=spacer.gif" height="1"></TD>
			</TR>
			<TR>
				<TD height="1" bgcolor="white"><IMG src="?drawimage=spacer.gif" height="1"></TD>
			</TR>
			<TR>
				<TD align="right" height="30">
					<input type="button" class="buttons" value="Update" style="width:<%#buttonwidth%>" name="btnok" onclick="submitform();" ID="Button1">
					<input type="button" class="buttons" value="Cancel" style="width:<%#buttonwidth%>" ID="btnCancel" onclick="window.close();">
				</TD>
			</TR>
		</TABLE>
	</form>
</BODY>
<SCRIPT>
		var mandatory="<%#mandatoryvalue%>";
		document.wf_theform.wf_textarea.focus();

		var valuediv = "<SELECT id='valueinput'>";
		valuediv += "<%#assignvalue%>";
		valuediv +=	"</SELECT>";

		var variablediv = "<SELECT id='valueinput'>";
		variablediv += "<%#assignvariables%>";
		variablediv +=	"</SELECT>";

		var contentdiv = "<SELECT id='valueinput'>";
		contentdiv += "<%#assigncontent%>";
		contentdiv +=	"</SELECT>";

		var oexpr2;

		oexpr2 = document.getElementsByTagName("div")["expr2"];

		Select3_onclick();

		function changeDiv( divvar )
		{
			if( !oexpr2 )
				oexpr2 = document.getElementsByTagName("div")["expr2"];

			oexpr2.innerHTML = eval(divvar);
		}

		function Select3_onclick()
		{
			var oselect3 = document.getElementsByTagName("select")["Select3"];

			switch(oselect3.value)
			{
				case "Value": changeDiv("valuediv");
							break;
				case "Variable": changeDiv("variablediv");
								break;

				case "Content": changeDiv("contentdiv");
								break;
				default: changeDiv("variablediv");
					     break;

			}

			return false;
		}

		function InsertField()
		{

			var oselect3 = document.getElementsByTagName("select")["Select3"];
			var ovalueinput = document.getElementsByTagName("select")["valueinput"];
			//alert(ovalueinput.value);
			var otextarea=document.wf_theform.wf_textarea;
			otextarea.value = otextarea.value + "<%#"+ovalueinput.value+"%>";
			document.wf_theform.wf_textarea.focus();

		}

	function trim(theString) //Remove Trailing spaces
	{
		while(""+theString.charAt(theString.length-1)==" ")
			theString = theString.substring(0, theString.length-1);
		while(""+theString.charAt(0)==" ")
			theString = theString.substring(1, theString.length);
		return(theString);
	}


	function submitform()
	{
		if(mandatory =="True" && trim(document.wf_theform.wf_textarea.value) =="")
		{
			alert('Value cannot be empty.')
			document.wf_theform.wf_textarea.focus();
			return false;
		}
		var height,width;
		if (document.all)
			{
				height = document.body.offsetHeight
				width = document.body.offsetWidth;
			}
		else if (document.layers)
			{
				height = window.innerHeight
				width = window.innerWidth;
			}
		window.opener.properties("_hidtempstore"," "+document.wf_theform.wf_textarea.value +'^~~^'+ height +'^~~^'+ width);
		window.opener.submitform("?mode=edit&<%#qspropertypagename%>=<%#propertypage%>&<%#qspropertyname%>=<%#propertyname%>&<%#SelectedItemQueryString%>")
		window.close();
	}
document.wf_theform.wf_textarea.focus();
function resizecontrols()
{
	document.wf_theform.wf_textarea.style.width = document.body.offsetWidth - 10
	document.wf_theform.wf_textarea.style.height= document.body.offsetHeight - 100
}
</SCRIPT>
